<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
	<fieldset class="layui-elem-field layui-field-title site-title">
		<legend>
			<a name="fixbar" style="font-size: 16px; color: #ce2424;">学员结业考试成绩</a>
		</legend>
	</fieldset>
	<form class="layui-form" id="myForm" method="post" lay-filter="stuform">
		<div class="layui-form-item">
			<div class="layui-inline" style="width: 350px;">
				<label class="layui-form-label">班级名称：</label>
				<div class="layui-input-block">
					<select id="bjid" lay-filter="bjselect" lay-verify="required"
						lay-search>
						<c:forEach var="d" items="${bjs}">
							<option value="${d.id}">${d.name}</option>
						</c:forEach>
					</select>
				</div>
			</div>
		</div>
	</form>
	
	<table id="performance_table" lay-filter="test3"></table>
	
	<script type="text/javascript">
		layui.use('form', function(){
			var form = layui.form;
			form.render();
			
			form.on('select(bjselect)', function(data){
				var id = data.value;
				layui.use("table", function(){
					var table = layui.table;
					table.reload('performance_table',{
						url:'student/page',
						where: {
							bjuuid : id
						}
					});
				});
			})
		})
		var bjid = $("#bjid").val();
		layui.use("table", function(){
			var search = {};
			var that = this;
			var table = layui.table;
			table.render({
				elem: '#performance_table',
				url: 'student/page',
				title: '学员结业考试成绩',
				height: 'full-260',
				where: {
					bjuuid : bjid,
					isUsed:true
				},
				page: true,
				cols : [ [ 
					{field : 'tbClass', title : '班级', templet : function(d) {
						return d.tbClass ? d.tbClass.name : '';
					}}, 
					{field : 'name', title : '姓名' },
					{field : 'performance', title : '成绩', edit: true}/* ,
					{field : 'points', title : '总分', edit: true} */
				] ]
			});
		});
		
		layui.use('table', function(){
			var table = layui.table;
			  
		  	//监听单元格编辑
		  	table.on('edit(test3)', function(obj){
		    	var value = obj.value //得到修改后的值
		    	,data = obj.data //得到所在行所有键值
		    	,field = obj.field; //得到字段
		    	var points = data.points;
		    	/* if(field == 'performance'){ */
		    		/* if(points == null){
		    			layui.use('layer', function(){
		    				layer.msg("请先填写总分");
		    			})
		    		}else if(points < value){
		    			layui.use('layer', function(){
		    				layer.msg("成绩不能大于总分");
		    			})
		    		}else{ */
		    			$.post("student/performanceSave?"+field+"="+value, {id: data.id}, function(){
				    		
				    	});
		    		/* } */
		    	/* } */
			});
		});
	</script>
</body>
</html>